<template>
  <div id="app">
    <router-view v-if="isRouterALive"></router-view>
  </div>
</template>

<script>
export default {
  name: 'app',
  metaInfo: {
    title: '奇缘', // set a title
    meta: [
      {
        // set meta
        name: '奇缘',
        content: '奇缘，欢迎大家交流学习'
      }
    ],
    link: [
      {
        // set link
        rel: 'asstes',
        href: 'http://www.yuuuu.vip'
      }
    ]
  },
  created () {
    // this.initCNZZ()
  },
  provide () {
    return {
      reload: this.reload
    }
  },
  data () {
    return {
      isRouterALive: true
    }
  },
  methods: {
    reload () {
      this.isRouterALive = false
      this.$nextTick(function () {
        this.isRouterALive = true
      })
    },
    initCNZZ () {
      // 添加脚本
      const script = document.createElement('script')
      script.src =
        'https://s9.cnzz.com/z_stat.php?id=1278283813111&web_id=1278283813111'
      script.language = 'JavaScript'
      script.id = 'cnzz'
      document.body.appendChild(script)
    }
  },

  watch: {
    $route: {
      handler (to, from) {
        setTimeout(() => {
          // 避免首次获取不到window._czc
          if (window._czc) {
            let location = window.location
            let contentUrl = location.pathname + location.hash
            let refererUrl = '/'
            // 用于发送某个URL的PV统计请求，
            window._czc.push(['_trackPageview', contentUrl, refererUrl])
          }
        }, 300)
      },
      immediate: true // 首次进入页面即执行
    }
  }
}
</script>

<style>
@import "assets/css/reset.css";
</style>
